
function getBacktest(dir, backtest)
{
    $.ajax({
        type: "post",
        data: {},
        url: "/strategys?method=get_backtest&dir="+dir+"&backtest="+backtest,
        dataType: "html",
        success: function (data) {
            $("#rightpage").html(data);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert(errorThrown);
        }
    });
}

function getStrategys()
{
    $.ajax({
        type: "post",
        data: {},
        url: "/strategys?method=get_strategys",
        dataType: "html",
        success: function (data) {
            $("#index_main_page").html(data);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert(errorThrown);
        }
    });
}

function getStrategysStat()
{
    $.ajax({
        type: "post",
        data: {},
        url: "/strategys?method=get_strategys_stat",
        dataType: "html",
        success: function (data) {
            $("#index_main_page").html(data);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert(errorThrown);
        }
    });
}


function getBacktestStat(title_en)
{
    $.ajax({
        type: "post",
        data: {},
        url: "/strategys?method=get_backtest_stat&title_en="+title_en,
        dataType: "html",
        success: function (data) {
            $("#mainpage").html(data);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert(errorThrown);
        }
    });
}


function getStrategy(dir)
{
    $.ajax({
        type: "post",
        data: {},
        url: "/strategys?method=get_strategy&dir="+dir,
        dataType: "html",
        success: function (data) {
            $("#mainpage").html(data);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert(errorThrown);
        }
    });
}

function getStrategyReadme(dir)
{
    $.ajax({
        type: "post",
        data: {},
        url: "/strategys?method=get_strategy_readme&dir="+dir,
        dataType: "html",
        success: function (data) {
            $("#rightpage").html(data);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert(errorThrown);
        }
    });
}

function getBacktestCount(dir, rank_field, rank_style)
{
     $.ajax({
        type: "post",
        data: {},
        url: "/strategys?method=get_backtest_count&dir="+dir+"&rank_field="+rank_field+"&rank_style="+rank_style,
        dataType: "html",
        success: function (data) {
            $("#rightpage").html(data);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert(errorThrown);
        }
    });
}

function getBacktestTrade(dir, backtest)
{
    $.ajax({
        type: "post",
        data: {},
        url: "/strategys?method=get_backtest_trade&dir="+dir+"&backtest="+backtest,
        dataType: "html",
        success: function (data) {
            $("#subpage").html(data);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert(errorThrown);
        }
    });
}

function getBacktestCash(dir, backtest)
{
    $.ajax({
        type: "post",
        data: {},
        url: "/strategys?method=get_backtest_cash&dir="+dir+"&backtest="+backtest,
        dataType: "html",
        success: function (data) {
            $("#subpage").html(data);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert(errorThrown);
        }
    });
}

function getBacktestPosition(dir, backtest)
{
    $.ajax({
        type: "post",
        data: {},
        url: "/strategys?method=get_backtest_position&dir="+dir+"&backtest="+backtest,
        dataType: "html",
        success: function (data) {
            $("#subpage").html(data);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert(errorThrown);
        }
    });
}

function getBacktestLog(dir, backtest)
{
    $.ajax({
        type: "post",
        data: {},
        url: "/strategys?method=get_backtest_log&dir="+dir+"&backtest="+backtest,
        dataType: "html",
        success: function (data) {
            $('#subpage').html(data);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert(errorThrown);
        }
    });
}

function getBacktestOverview()
{
    $('#subpage').html($('#subpage_overview').html());
}

function showBacktestStock(code)
{
    rawData = [["2004-01-02",10452.74,10409.85,10367.41,10554.96,168890000],["2004-01-05",10411.85,10544.07,10411.85,10575.92,221290000],["2004-01-06",10543.85,10538.66,10454.37,10584.07,191460000],["2004-01-07",10535.46,10529.03,10432,10587.55,225490000],["2004-01-08",10530.07,10592.44,10480.59,10651.99,237770000],["2004-01-09",10589.25,10458.89,10420.52,10603.48,223250000],["2004-01-12",10461.55,10485.18,10389.85,10543.03,197960000],["2004-01-13",10485.18,10427.18,10341.19,10539.25,197310000],["2004-01-14",10428.67,10538.37,10426.89,10573.85,186280000],["2004-01-15",10534.52,10553.85,10454.52,10639.03,260090000],["2004-01-16",10556.37,10600.51,10503.7,10666.88,254170000],["2004-01-20",10601.4,10528.66,10447.92,10676.96,224300000],["2004-01-21",10522.77,10623.62,10453.11,10665.7,214920000],["2004-01-22",10624.22,10623.18,10545.03,10717.4,219720000],["2004-01-23",10625.25,10568.29,10490.14,10691.77,234260000],["2004-01-26",10568,10702.51,10510.44,10725.18,186170000],["2004-01-27",10701.1,10609.92,10579.33,10748.81,206560000],["2004-01-28",10610.07,10468.37,10412.44,10703.25,247660000],["2004-01-29",10467.41,10510.29,10369.92,10611.56,273970000],["2004-01-30",10510.22,10488.07,10385.56,10551.03,208990000],["2004-02-02",10487.78,10499.18,10395.55,10614.44,224800000],["2004-02-03",10499.48,10505.18,10414.15,10571.48,183810000],["2004-02-04",10503.11,10470.74,10394.81,10567.85,227760000],["2004-02-05",10469.33,10495.55,10399.92,10566.37,187810000],["2004-02-06",10494.89,10593.03,10433.7,10634.81,182880000],["2004-02-09",10592,10579.03,10433.7,10634.81,160720000],["2004-02-10",10578.74,10613.85,10511.18,10667.03,160590000],["2004-02-11",10605.48,10737.7,10561.55,10779.4,277850000],["2004-02-12",10735.18,10694.07,10636.44,10775.03,197560000],["2004-02-13",10696.22,10627.85,10578.66,10755.47,208340000],["2004-02-17",10628.88,10714.88,10628.88,10762.07,169730000],["2004-02-18",10706.68,10671.99,10623.62,10764.36,164370000],["2004-02-19",10674.59,10664.73,10626.44,10794.95,219890000],["2004-02-20",10666.29,10619.03,10559.11,10722.77,220560000],["2004-02-23",10619.55,10609.62,10508.89,10711.84,229950000],["2004-02-24",10609.55,10566.37,10479.33,10681.4,225670000],["2004-02-25",10566.59,10601.62,10509.4,10660.73,192420000],["2004-02-26",10598.14,10580.14,10493.7,10652.96,223230000],["2004-02-27",10581.55,10583.92,10519.03,10689.55,200050000],["2004-03-01",10582.25,10678.14,10568.74,10720.14,185030000],["2004-03-02",10678.36,10591.48,10539.4,10713.92,215580000],["2004-03-03",10588.59,10593.11,10506.66,10651.03,188800000],["2004-03-04",10593.48,10588,10522.59,10645.33,161050000],["2004-03-05",10582.59,10595.55,10497.11,10681.4,223550000],["2004-03-08",10595.37,10529.48,10505.85,10677.85,199300000],["2004-03-09",10529.52,10456.96,10391.48,10567.03,246270000],["2004-03-10",10457.59,10296.89,10259.34,10523.11,259000000],["2004-03-11",10288.85,10128.38,10102.75,10356.22,292050000],["2004-03-12",10130.67,10240.08,10097.04,10281.63,223350000],["2004-03-15",10238.45,10102.89,10066.08,10252.68,219150000],["2004-03-16",10103.41,10184.67,10085.34,10253.26,194560000],["2004-03-17",10184.3,10300.3,10184.3,10356.59,181210000],["2004-03-18",10298.96,10295.78,10187.78,10355.04,218820000],["2004-03-19",10295.85,10186.6,10163.71,10355.41,261590000],["2004-03-22",10185.93,10064.75,9985.19,10185.93,248930000],["2004-03-23",10066.67,10063.64,10020.75,10177.04,215260000],["2004-03-24",10065.41,10048.23,9975.86,10140.23,224310000],["2004-03-25",10049.56,10218.82,10049.56,10246.15,216420000],["2004-03-26",10218.37,10212.97,10145.63,10306.22,198830000],["2004-03-29",10212.91,10329.63,10212.91,10389.93,197150000],["2004-03-30",10327.63,10381.7,10264.15,10411.41,189060000],["2004-03-31",10380.89,10357.7,10287.11,10428.59,207400000],["2004-04-01",10357.52,10373.33,10299.48,10449.33,218660000],["2004-04-02",10375.33,10470.59,10375.33,10548.74,243070000],["2004-04-05",10470.59,10558.37,10423.33,10582.22,182130000],["2004-04-06",10553.76,10570.81,10467.26,10596.37,175720000],["2004-04-07",10569.26,10480.15,10422.74,10580.51,218040000],["2004-04-08",10482.77,10442.03,10383.84,10590.15,187730000],["2004-04-12",10444.38,10515.56,10439.27,10559.28,142190000],["2004-04-13",10516.05,10381.28,10343.17,10572.13,202540000],["2004-04-14",10378.1,10377.95,10259.35,10453.39,230460000],["2004-04-15",10377.95,10397.46,10279.37,10481.21,262880000],["2004-04-16",10398.32,10451.97,10343.74,10500.57,234660000],["2004-04-19",10451.62,10437.85,10351.97,10501.79,173340000],["2004-04-20",10437.85,10314.5,10297.39,10530.61,204710000],["2004-04-21",10311.87,10317.27,10200.38,10398.53,232630000],["2004-04-22",10314.99,10461.2,10255.88,10529.12,265740000],["2004-04-23",10463.11,10472.84,10362.97,10543.95,277070000],["2004-04-26",10472.91,10444.73,10396.75,10540.26,183040000],["2004-04-27",10445.38,10478.16,10410.52,10570.92,213410000],["2004-04-28",10476.67,10342.6,10301.65,10479.58,232090000],["2004-04-29",10339.41,10272.27,10199.31,10443.81,231880000],["2004-04-30",10273.06,10225.57,10198.39,10374.61,218010000],["2004-05-03",10227.27,10314,10199.67,10365.74,198830000],["2004-05-04",10314.32,10317.2,10232.31,10403.14,208020000],["2004-05-05",10316.98,10310.95,10249.63,10382.98,172170000],["2004-05-06",10308.2,10241.26,10147.21,10332.1,202690000],["2004-05-07",10240.62,10117.34,10086.94,10302.93,228140000],["2004-05-10",10116.28,9990.02,9881.86,10116.28,272130000],["2004-05-11",9989.24,10019.47,9928.91,10092.78,223650000],["2004-05-12",10011.52,10045.16,9822.1,10089.87,246410000],["2004-05-13",10044.31,10010.74,9924.94,10100.24,215300000],["2004-05-14",10008.43,10012.87,9912.45,10096.69,175180000],["2004-05-17",10009.92,9906.91,9827.21,10009.92,199660000],["2004-05-18",9906.71,9968.51,9895.77,10028.27,191770000],["2004-05-19",9962.55,9937.71,9919.9,10124.79,227420000],["2004-05-20",9939.12,9937.64,9867.73,10014.5,155570000],["2004-05-21",9939.34,9966.74,9910.81,10058.5,180980000],["2004-05-24",9968.02,9958.43,9891.22,10084.91,187000000],["2004-05-25",9958.08,10117.62,9895.41,10139.27,213950000],["2004-05-26",10116.84,10109.89,10034.16,10175.75,171700000],["2004-05-27",10109.89,10205.2,10106.13,10267.66,186670000],["2004-05-28",10205.83,10188.45,10137.14,10250.27,159560000],["2004-06-01",10187.18,10202.65,10104.07,10254.17,166590000],["2004-06-02",10199.78,10262.97,10170.57,10310.1,183540000],["2004-06-03",10261.85,10195.91,10163.4,10309.46,162840000],["2004-06-04",10196.83,10242.82,10196.83,10327.84,161190000],["2004-06-07",10243.31,10391.08,10243.31,10410.81,172490000],["2004-06-08",10389.41,10432.52,10323.94,10462.97,170220000],["2004-06-09",10431.1,10368.44,10325.07,10466.59,175090000],["2004-06-10",10367.8,10410.1,10333.94,10448,154090000],["2004-06-14",10401.23,10334.73,10283.48,10403.5,166530000],["2004-06-15",10336.51,10380.43,10319.89,10464.04,223780000],["2004-06-16",10380.23,10379.58,10320.6,10433.52,153020000],["2004-06-17",10378.59,10377.52,10308.25,10417.69,169820000],["2004-06-18",10375.82,10416.41,10328.2,10471.84,300680000],["2004-06-21",10417.82,10371.47,10336.44,10471.76,175300000],["2004-06-22",10370.21,10395.07,10284.24,10431.05,203470000],["2004-06-23",10395.14,10479.57,10323.32,10498.67,210770000],["2004-06-24",10477.43,10443.81,10398.16,10530.01,214330000],["2004-06-25",10444.24,10371.84,10329.88,10514.67,308250000],["2004-06-28",10377.52,10357.09,10317.64,10505.16,231100000],["2004-06-29",10356.35,10413.43,10315.65,10460.25,180210000],["2004-06-30",10413.43,10435.48,10348.98,10489.16,227800000],["2004-07-01",10434,10334.16,10255.55,10473.23,234900000],["2004-07-02",10334,10282.83,10228.71,10371.4,146600000],["2004-07-06",10280.26,10219.34,10163.6,10308.43,180070000],["2004-07-07",10211.92,10240.29,10156.45,10300.53,179940000],["2004-07-08",10238.52,10171.56,10134.99,10297.73,181790000],["2004-07-09",10173.12,10213.22,10150.32,10277.16,161230000],["2004-07-12",10211.75,10238.22,10130.42,10284.39,155520000],["2004-07-13",10238.37,10247.59,10188.45,10297.58,160630000],["2004-07-14",10232.84,10208.8,10129.31,10313.95,298900000],["2004-07-15",10208.2,10163.16,10115.81,10275.27,231930000],["2004-07-16",10162.34,10139.78,10095.32,10289.4,267310000],["2004-07-19",10140.95,10094.06,10027.33,10211.6,198380000],["2004-07-20",10094.43,10149.07,10031.24,10186.9,197640000],["2004-07-21",10156.3,10046.13,10027.92,10279.96,277570000],["2004-07-22",10047.6,10050.33,9906.62,10114.41,247870000],["2004-07-23",10045.46,9962.22,9893.93,10069.51,238540000],["2004-07-26",9964.71,9961.92,9874.38,10054.32,221240000],["2004-07-27",9963.54,10085.14,9942.75,10133.95,236270000],["2004-07-28",10084.03,10117.07,9966.34,10170.31,223560000],["2004-07-29",10115.52,10129.24,10049.74,10213.08,215050000],["2004-07-30",10129.12,10139.71,10045.76,10194.13,197240000],["2004-08-02",10138.45,10179.16,10063.75,10224.29,177330000],["2004-08-03",10178.27,10120.24,10064.57,10228.49,190880000],["2004-08-04",10117.96,10126.51,10029.02,10186.16,157430000],["2004-08-05",10127.1,9963.03,9945.84,10158.44,178250000],["2004-08-06",9960.67,9815.33,9767.54,9963.47,215870000],["2004-08-09",9816.14,9814.66,9773.74,9902.49,148320000],["2004-08-10",9815.55,9944.67,9798.44,9961.7,167590000],["2004-08-11",9931.24,9938.32,9804.63,9981.61,182920000],["2004-08-12",9936.48,9814.59,9780.52,9940.02,248090000],["2004-08-13",9814.11,9825.35,9746.6,9897.34,182590000],["2004-08-16",9825.35,9954.55,9807.44,9987.58,176390000],["2004-08-17",9955.5,9972.83,9916.05,10053.21,186120000],["2004-08-18",9964.22,10083.15,9910.82,10097.01,187150000],["2004-08-19",10082.78,10040.82,9972.39,10111.91,162780000],["2004-08-20",10040.81,10110.14,9989.65,10143.76,175000000],["2004-08-23",10111.1,10073.05,10046.72,10159.54,144500000],["2004-08-24",10074.89,10098.63,10044.66,10165.07,143050000],["2004-08-25",10098.49,10181.74,10041.93,10224.29,172570000],["2004-08-26",10181.07,10173.41,10124.88,10225.61,131960000],["2004-08-27",10174.07,10195.01,10143.91,10235.49,114580000],["2004-08-30",10193.83,10122.52,10110.43,10226.87,114850000]];
    showBacktestStockChar(rawData);
    $('#backtestStockModal').modal("show");
}